package com.zhoushihao.class0820;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Award {
    public static void main(String[] args) {
        List<Students> students = new ArrayList<>();
        int sumAward = 0;
        try (
                BufferedReader br = new BufferedReader(new FileReader("./src/com/neusoft/zhoushihao/class0820/input.txt"));
                BufferedWriter bw = new BufferedWriter(new FileWriter("./src/com/neusoft/zhoushihao/class0820/output.txt"))
        ) {
            String line;
            int count = 0;
            while ((line = br.readLine()) != null) {
                String[] data = line.split(" ");
                if(data.length == 6) {
                    Students student = new Students(data[0],Integer.parseInt(data[1]),Integer.parseInt(data[2]),data[3],data[4],Integer.parseInt(data[5]),++count);
                    student.getTotalAward();
                    sumAward+=student.totalAward;
                    students.add(student);
                }
            }
            Collections.sort(students);
            bw.write(students.get(students.size()-1).name);
            bw.newLine();
            bw.write(String.valueOf(students.get(students.size()-1).totalAward));
            bw.newLine();
            bw.write(String.valueOf(sumAward));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
class Students implements Comparable<Students>{
    String name;
    int endScore;
    int classScore;
    String cadre;
    String westStudent;
    int paperNum;
    int totalAward;
    int num;

    public Students(String name, int endScore, int classScore, String cadre, String westStudent, int paperNum,int num) {
        this.name = name;
        this.endScore = endScore;
        this.classScore = classScore;
        this.cadre = cadre;
        this.westStudent = westStudent;
        this.paperNum = paperNum;
        this.num = num;
    }
    public void getTotalAward() {
        int award = 0;
        if(this.endScore > 80 && paperNum > 0) {
            award+=8000;
        }
        if(this.endScore > 85 && this.classScore > 80){
            award+=4000;
        }
        if(this.endScore > 90){
            award+=2000;
        }
        if(this.endScore > 85 && this.westStudent.equals("Y")){
            award+=1000;
        }
        if(this.classScore > 80 && this.cadre.equals("Y")){
            award+=850;
        }
        this.totalAward = award;
    }

    @Override
    public int compareTo(Students o) {
        if(this.totalAward == o.totalAward) {
            return o.num - this.num;
        }else{
            return this.totalAward - o.totalAward;
        }
    }
}
